#ifndef __LIB_KERNEL_IO_QUEUE_H
#define __LIB_KERNEL_IO_QUEUE_H

#include "stdint.h"
#include "sync.h"
#include "thread.h"


#define IO_QUEUE_BUF_SIZE       10

struct ioqueue{
    /* 用于多生产者多消费者的锁 */
    struct lock lock;
    /* 保存休眠的生产者和消费者 */
    struct task_struct* consumer;
    struct task_struct* producer;
    /* 缓冲区 */
    char buf[IO_QUEUE_BUF_SIZE];
    /* 写入数据从头写入 读取数据从尾读出 即先进先出fifo */
    int32_t head;
    int32_t tail;
};
uint8_t ioqueue_empty(struct ioqueue* ioq);
uint8_t ioqueue_full(struct ioqueue* ioq);
char ioqueue_get_char(struct ioqueue* ioq);
void ioqueue_put_char(struct ioqueue* ioq, char ch);
void ioqueue_init(struct ioqueue* ioq);

#endif